package neu.soft.listener;

import neu.soft.entity.OperationPurchaseOrder;
import neu.soft.facade.PurchaseComprehensiveFacade;
import neu.soft.vo.MsgBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;

/**
 * @author 李博
 * 采购服务监听
 */
@Component
public class SupplyListener {

    @Autowired
    PurchaseComprehensiveFacade purchaseComprehensiveFacade;

    // 监听业务中心发来的购货单
    @StreamListener("financial-supply-input")
    public void receiveSupplyMsg(OperationPurchaseOrder operationPurchaseOrder) {

        purchaseComprehensiveFacade.receivePurchaseOrder(operationPurchaseOrder);

    }

    //监听中心库房的通知。
    @StreamListener("financial-warehouse-input")
    public void receiveWarehouseMsg(@Payload MsgBean msgBean) {

        Integer purchaseOrderId = (Integer) msgBean.getData();
        purchaseComprehensiveFacade.generatePayableOrder(purchaseOrderId);
    }

}
